
//抽奖
var openRedBagPage = document.querySelector('.open-red-bag');
var openRedBag = document.querySelector('.not-open-red-bag');
var lotteryPage = document.querySelector('.lottery-page');
var lotteryResult = lotteryPage.querySelector('.be-opend-red-bag').children[0];
var opacity = 9;
$('.not-open-red-bag').one('touchstart',function(){
	this.classList.add('shake');
	setTimeout(function(){
		opacityStop = setInterval(function(){
			if(opacity <= 0){
				clearInterval(opacityStop);
				openRedBagPage.style.display = 'none';
				randomLottery();
				lotteryPage.style.display = 'block';
			}
			opacity--;
			openRedBagPage.style.opacity = '0.' + opacity  + '';
		},150);
	},1000);

})

var resultArr = [
	'lottery_1.png',
	'lottery_2.png',
	'lottery_3.png',
	'lottery_4.png',
	'lottery_5.png',
	'lottery_6.png',
	'be_opened_red_bag.png'
];

function randomLottery(){
	num = parseInt(Math.random() * 7 + 0);
	lotteryResult.src = 'img/lottery/' + resultArr[num];
}

//领奖登记
var recordBtn = document.querySelector('.lottery-btn-group').children[0];
var recordPage = document.querySelector('.lottery-record');
recordBtn.addEventListener('touchstart',function(){
	recordPage.style.display = 'block'
});

//结束禁止跳转

document.querySelector('.submit').addEventListener('touchstart',function(e){
	e.preventDefault();
})